package org.jheuristics.ga.operators;

import java.io.Serializable;

import org.jheuristics.ga.operators.closures.PopulationClearClosure;

/**
 * TODO
 *
 * @author Marcell Manfrin, marcell@ourgrid.org, Jan 9, 2006
 */
public class SelectionClearingOperator extends SelectionOperator implements Serializable {

	/**
	 * TODO
	 *
	 * @param rate
	 * @param selector
	 * @param fromPopChooser
	 * @param cleanAfterFromPop
	 * @param toPopChooser
	 * @param cleanBeforeToPop
	 */
	public SelectionClearingOperator(Rate rate, Selector selector, PopulationChooser fromPopChooser, boolean cleanAfterFromPop, PopulationChooser toPopChooser, boolean cleanBeforeToPop) {
		super(rate, selector, fromPopChooser, toPopChooser);
		ClosureSelection clearing = new PopulationClearClosure();
		if (cleanAfterFromPop) {
			setAfterSelectionClosure(clearing);
		}
		if (cleanBeforeToPop) {
			setBeforeInsertionClosure(clearing);
		}
	}

	public SelectionClearingOperator(Rate rate, Selector selector, PopulationChooser fromPopChooser, ClosureSelection afterSelectionClosure, PopulationChooser toPopChooser, ClosureSelection beforeInsertionClosure) {
		super(rate, selector, fromPopChooser, toPopChooser);
		setAfterSelectionClosure(afterSelectionClosure);
		setBeforeInsertionClosure(beforeInsertionClosure);
	}

}
